switchroot: Bind mount /lib/modules after we mount /lib
authorColin Walters <walters@verbum.org>
Mon, 13 Feb 2012 15:56:13 +0000 (10:56 -0500)
committerColin Walters <walters@verbum.org>
Mon, 13 Feb 2012 15:56:13 +0000 (10:56 -0500)
Otherwise we don't ge the right /lib/modules.

src/switchroot/ostree-switch-root.c

index 3e1155c03d318357fa941255111f274ab3625da7..60306e6c347c746cbd2f7c62a100679c467a7a7a 100644 (file)
@@ -283,14 +283,6 @@ main(int argc, char *argv[])
        }
     }
 
-  snprintf (srcpath, sizeof(srcpath), "/ostree/modules");
-  snprintf (destpath, sizeof(destpath), "/ostree/%s/lib/modules", ostree_target);
-  if (mount (srcpath, destpath, NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
-    {
-      perrorv ("failed to bind mount (class:bind) %s to %s", srcpath, destpath);
-      exit (1);
-    }
-
   for (i = 0; readonly_bind_mounts[i] != NULL; i++)
     {
       snprintf (destpath, sizeof(destpath), "/ostree/%s%s", ostree_target, readonly_bind_mounts[i]);
@@ -305,7 +297,16 @@ main(int argc, char *argv[])
          exit (1);
        }
     }
-  
+
+  /* This should come after we've bind mounted /lib */
+  snprintf (srcpath, sizeof(srcpath), "/ostree/modules");
+  snprintf (destpath, sizeof(destpath), "/ostree/%s/lib/modules", ostree_target);
+  if (mount (srcpath, destpath, NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
+    {
+      perrorv ("failed to bind mount %s to %s", srcpath, destpath);
+      exit (1);
+    }
+
   snprintf (destpath, sizeof(destpath), "/ostree/%s", ostree_target);
   if (chroot (destpath) < 0)
     {